Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor controller to use functional routing #7809

Merged
merged 4 commits into from
Sep 25, 2024

Conversation

nathphon
Copy link
Contributor

Replaces the annotation-based controller with a functional routing approach. Introduces a RouterFunction bean to handle HTTP requests, eliminates redundant response creation, and improves efficiency by directly parsing path variables.

Replaces the annotation-based controller with a functional routing approach. Introduces a `RouterFunction` bean to handle HTTP requests, eliminates redundant response creation, and improves efficiency by directly parsing path variables.
Simplified the route definitions by using lambda expressions directly in the RouterFunction. This reduces unnecessary method declarations and enhances readability.
@waghanza
Copy link
Collaborator

Thanks @nathphon for this suggestion.

What is the best approach for a server side app (typically an API) ? This implementation, or this old one ?

Please, give me some insights, not in java world 😀

@nathphon
Copy link
Contributor Author

nathphon commented Sep 24, 2024

@waghanza in very high-throughput systems, the functional style (RouterFunction) may have a slight edge due to its more lightweight design, bypassing some of the overhead involved in handling annotations.

and i re write code to be the same style with ActiveJ

can you please review and merge this pr

@waghanza
Copy link
Collaborator

What do you think @whiplash ? is this considered as a best-practice (and production-read) ?

@waghanza
Copy link
Collaborator

cc @mmaryo

@whiplash
Copy link
Contributor

It all makes sense to me. It appears that using Spring these days you have a choice between going MVC of WebFlux. WebFlux seems to have pushed more on the functional pedal (which I tend to prefer). So It makes sense to have both.
As far as I can tell, the code here is the idiomatic way using WebFlux.

@waghanza
Copy link
Collaborator

Ok, so using webfux, like functional way seems to be the way to go.

But the same impl is no the way to go with the MVC approach.

Ok ❤️

@waghanza
Copy link
Collaborator

nathphon.jeamjit added 2 commits September 25, 2024 02:33
This change aligns the class name with its intended functionality. The class was previously named incorrectly, which could cause confusion. The new name clarifies its role as a controller within the Spring WebFlux framework.
This change corrects a package naming inconsistency in the BenchmarkController class. The package was previously listed incorrectly as "router" and has been updated to "controller" to reflect its actual content and functionality.
@waghanza waghanza enabled auto-merge (squash) September 25, 2024 11:42
@waghanza waghanza merged commit 003efe8 into the-benchmarker:master Sep 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants